package cf;

import java.util.Scanner;

public class APICount {

    public static int getResult(String[] api, int ceng,String apiStr) {
        int ans = 0;
        for (int i = 0; i < api.length; i++) {
            String[] chars = api[i].substring(1).split("/");
            if (chars.length >= ceng && chars[ceng - 1].equals(apiStr)) {
                ans ++;
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String[] api = new String[n];
        for (int i = 0; i < n; i++) {
            api[i] = sc.nextLine();
        }
        String tmp = sc.nextLine();
        int ceng = Integer.parseInt(tmp.split(" ")[0]);
        String apiStr =tmp.split(" ")[1];
        System.out.println(getResult(api,ceng,apiStr));
    }
}
